package demo1;

public class Computer{
    public static void IUSB(IUSB iusb){
        iusb.openDevice();
        if(iusb instanceof Mouse){
            Mouse mouse = (Mouse) iusb;
            mouse.click();
        }else if(iusb instanceof KeyBoard){
            KeyBoard keyBoard = (KeyBoard) iusb;
            keyBoard.inPut();
        }
        iusb.closeDevice();
    }
    public static void powerOf(){
        System.out.println("打开电脑...");
    }
    public static void powerOn(){
        System.out.println("关闭电脑...");
    }

    public static void main(String[] args) {
        Mouse mouse = new Mouse();
        KeyBoard keyBoard = new KeyBoard();
        powerOf();
        IUSB(mouse);
        IUSB(keyBoard);
        powerOn();
    }
}
